package com.cm.stock.manager.service;


import com.cm.stock.manager.dao.UserDAO;
import com.cm.stock.manager.dto.UserDTO;
import com.cm.stock.manager.utils.CMStockManagerUtils;

public class UserService {
	
	
	private UserDAO userDAO;
	
	public UserDTO doLogin(String login, String pwd){
		
		String cypherpwd = CMStockManagerUtils.encrypt(pwd, "Blowfish");
		return userDAO.getByLoginPassword(login, cypherpwd);
	}
	
	
	public UserDTO saveUser(String lastName, String firstName, String phone1,String phone2, String login, String pwd,boolean isAdmin){
		String code = userDAO.getMaxId()+"";
		String cypherpwd = CMStockManagerUtils.encrypt(pwd, "Blowfish");
		return userDAO.save(new UserDTO(code, lastName, firstName, phone1, phone2, login, cypherpwd, isAdmin, CMStockManagerUtils.CURRENT_USER.getPointVente()));
		
	}


	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}
	
	

}
